package com.jiudaoliu.homeprototype.utils;

import com.jiudaoliu.homeprototype.entity.IpAddr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class IpUtils {

    @Autowired
    private RestTemplate restTemplate;

    public IpAddr getIpAdderss(String ip) {
        String url = "http://ip-api.com/json/" + ip;
        IpAddr ipAddr = restTemplate.getForObject(url, IpAddr.class);
        return ipAddr;
    }

}